<?php namespace Home\Controller; 
use Think\Controller; 
class MsgController extends CommonController
{     
	public function index()
	{
		$uid=$_SESSION['id'];
		$sql="select t1.*, t2.title, t2.id as qid, t3.id as uid, t3.nickname from msg t1 inner join question t2 on t1.dst_qid=t2.id inner join user t3 on t1.event_id=t3.id where dst_user_id='{$uid}'";
		$res=M()->query($sql);
		$this->assign('mymsg',$res);
		$this->display();

	}

	public function delmsg()
	{
		$id=$_POST['data'];
		if(M('msg')->where(array('id'=>$id))->delete()){
			$arr= array(
				'error'=>0,
				'info'=>'删除成功，即将刷新页面'
				);
			echo json_encode($arr);
	    	exit;
		}else{
			$arr= array(
				'error'=>1,
				'info'=>'操作失败，请稍候重试'
				);
			echo json_encode($arr);
	    	exit;
		}
	}

}
?>